<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item label="">
        <el-col :span="6">
          <el-form-item prop="timeScope">
            <el-select v-model="formInline.dateType" placeholder="请选择时间范围">
              <el-option label="转账时间" :value="1"></el-option>
              <el-option label="处理时间" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="14">
          <el-form-item prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              :default-time="['00:00:00', '23:59:59']"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :picker-options="pickerDayStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="处理状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择状态">
          <el-option
            v-for="item in consts.TRANSFER_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="处理人" prop="operator">
        <el-select v-model="formInline.operator" placeholder="请选择状态">
          <el-option
            v-for="item in approverList"
            :label="item === '' ? '全部' : item"
            :key="item"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="来自" prop="fromChannel">
        <el-select
          v-model="formInline.fromChannel"
          @change="fromChannelChange"
          placeholder="请选择来自">
          <el-option
            :disabled="formInline.toChannel === item.value"
            v-for="item in consts.TRANSFER_PLATFORMS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="转至" prop="toChannel">
        <el-select
          @change="toChannelChange"
          v-model="formInline.toChannel" placeholder="请选择转至">
          <el-option
            :disabled="formInline.fromChannel === item.value"
            v-for="item in consts.TRANSFER_PLATFORMS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="订单号" prop="tradeId">
        <el-input v-model="formInline.tradeId" placeholder="请输入用户名" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-form-item prop="username" label="账户名">
        <el-input v-model="formInline.username" placeholder="请输入" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
<!--      <el-form-item label="姓名" prop="reallyName">-->
<!--        <el-input v-model="formInline.reallyName" placeholder="请输入姓名" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="手机号" prop="telephone">-->
<!--        <el-input v-model="formInline.telephone" placeholder="请输入手机号" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>-->
<!--      </el-form-item>-->
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
  import {getTransferExceptionsApprover} from '@/services/api/transfer'
  import {form, pickerOption} from '@/build'

  export default {
    name: "exception-filter",
    mixins: [form, pickerOption],
    data() {
      return {
        withdrawShopList: [],
        approverList:[],
        formInline: {
          time: [moment().format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
          dateType: 1,
          toChannel: undefined,
          fromChannel: undefined,
          minAmount: undefined,
          maxAmount: undefined,
          status: undefined,
          operator: undefined,
          reallyName: undefined,
          telephone: undefined,
          tradeId: undefined,
        },
      }
    },
    methods: {
      selfResetForm(formName) {
        this.resetForm(formName)
        this.$parent.getAll()
      },
      toChannelChange(val){
        if(val!==0){
          this.formInline.fromChannel = 0
        }
      },
      fromChannelChange(val){
        if(val!==0){
          this.formInline.toChannel = 0
        }
      },
    },
    mounted() {
      this.bindGet(getTransferExceptionsApprover, 'approverList', {
      });
      this.getAll()
    }
  }
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
